<?php
	####################################################
	# library import and object instance.              #
	####################################################
	include_once('./common.php');


	####################################################
	# request data($_POST AND $_GET FROM $_REQUEST)    #
	####################################################
	# REQUEST(get and post variables)
	$req = Request::clean_request($_REQUEST, FALSE);

	# GET(url variables)

	# POST(form variables)

	# Validation(special case validate)
	//*/
	Validation::check_is_emptys($req);
	Validation::check_is_idpw($req['mid']);
	Validation::check_is_idpw($req['mpasswd']);
	//Nlog::xmp($req); //display clean and remmap values
	//*/
	####################################################
	# implementation                                   #
	####################################################
	//*/
	# 사인 지속
	#when type example right text>> y|naiyumie (encrypted)
	if($req['sign_duration'] == 'y'){
		Cookier::set('sign_duration_cookie', 'y'.Cookier::$separate_key.Cipher::encrypt($req['mid']));
	} else {
		Cookier::del('sign_duration_cookie');
	}

	#로그인이 정보 일치 확인
	$ret = $db->get(
		sprintf("SELECT * FROM n_member WHERE mid='%s' AND mpasswd='%s'",
			$req['mid'],
			$req['mpasswd']
		)
	);
	if($ret['has']){
		$dbsess->sess_save(array("muid"=>$ret['res']['muid']));
	}
	//Nlog::xmp($ret);
	//*/
?>
<?php
	$html->custom_header(TITLE);
	$html->custom_js("{$JS}jquery.1.7.1.min.js");
	$html->custom_js("{$JS}lib.control.js");
	$html->custom_css("{$CSS}basic.css");
?>
<?$html->custom_body();?>
<?=$tmp->tiles_header()?>
	<h1>로그인</h1>
	<?php if($ret['has']): ?>
		로그인 성공
	<?php else: ?>
		로그인 실패 아이디 패스워드를 확인 하세요.
	<?php endif; ?>
	<br />
	<?=NTool::btn("뒤로", "Mover.back();");?>
	<?=NTool::btn("인덱스", "Mover.home();");?>
<?=$tmp->tiles_footer()?>
<?php $html->html_footer(); ?>